package worldLogic;

import java.util.HashMap;

public class World extends Thread {

    private HashMap<Integer, Ant> ants;
    private Map map;

    private Integer width;
    private Integer height;

    private Boolean pause;
    private Boolean live;


    public World(int width, int height) {
        this.width = width;
        this.height = height;
        map = new Map(width, height);
    }

    public void addAnt(Ant newAnt) {

    }        

    public void run() {
        pause = false;
        live = true;
        while (live) {
            while (!pause) {
                for (Ant ant : ants.values()) {
                    //**********************
                    //Process each ant
                    //**********************
                    //Smell
                    for (PhysicalObject smelledObject : map.getObjectsInRadius(ant.getSmellRadius(), ant.getLocation()))
                    {
                        if (smelledObject instanceof Smells) {
                            ant.queueEvent(new SmellEvent(((Smells) smelledObject).getOdor(), smelledObject.getLocation()));
                        }
                    }

                    //Talk

                    //Sight

                    //Collision

                    ant.think();

                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException e) {
                    }
                }

                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                }
            }
        }

    }

    public void setPause(Boolean pause) {
        this.pause = pause;
    }

    public void setLive(Boolean live) {
        this.live = live;
    }

}


